#include "UpperSetMacParamCmd.h"

UpperSetMacParamCmd::UpperSetMacParamCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::CloudProtocol;
    this->m_functionCode = FunctionCode;
}

Package UpperSetMacParamCmd::toPackage()
{
    Package package;
    return package;
}

void UpperSetMacParamCmd::unPackage(Package package)
{
    m_cmdId = package.id();
    QByteArray body;

    body = decrypt(package.body(),KeyType::AES);

    quint16 index = 0;
    quint16 strLength;

    strLength = body.mid(index,2).toHex().toInt(0,16);
    index += 2;
    m_mac = body.mid(index,strLength);
    index += strLength;

    strLength = body.mid(index,2).toHex().toInt(0,16);
    index += 2;
    m_registrationDateBCD = body.mid(index,strLength);
    index += strLength;

    strLength = body.mid(index,2).toHex().toInt(0,16);
    index += 2;
    m_registrant = body.mid(index,strLength);
    index += strLength;
}

QString UpperSetMacParamCmd::mac() const
{
    return m_mac;
}

void UpperSetMacParamCmd::setMac(const QString &mac)
{
    m_mac = mac;
}

QString UpperSetMacParamCmd::registrant() const
{
    return m_registrant;
}

void UpperSetMacParamCmd::setRegistrant(const QString &registrant)
{
    m_registrant = registrant;
}

QByteArray UpperSetMacParamCmd::registrationDateBCD() const
{
    return m_registrationDateBCD;
}

void UpperSetMacParamCmd::setRegistrationDateBCD(const QByteArray &registrationDateBCD)
{
    m_registrationDateBCD = registrationDateBCD;
}
